#!/bin/env python
#coding:utf-8
__author__ = 'mason'
from django.contrib import admin

# Register your models here.

from . import models
class BusinessGroupAdin(admin.ModelAdmin):
    list_display = [ 'rank', 'chinese_name', 'english_name', 'desc', 'applications']
    def applications(self, obj):
        return [ i.name for i in obj.packagename_set.all()]

class TeamUserAdmin(admin.ModelAdmin):
    list_display = [ 'rank', 'chinese_name', 'english_name', 'email', 'phone_num', 'is_leader', 'is_disable']

class PackageNameAdmin(admin.ModelAdmin):
    list_display = ['rank', 'name', 'groups', 'user']
    list_filter =  ('business_group', 'team_user')
    def groups(self, obj):
        return [bt.english_name for bt in obj.business_group.all()]
    def user(self, obj):
        return [bt.english_name for bt in obj.team_user.all()]

admin.site.register(models.BusinessGroup, BusinessGroupAdin)
admin.site.register(models.TeamUser, TeamUserAdmin)
admin.site.register(models.PackageName, PackageNameAdmin)